/*
 * instructionTable.c
 *
 *  Created on: May 10, 2014
 *      Author: Hercules
 */
#include "instructionTable.h"

InstructionTable* createInstructionTable() {
	InstructionTable* tb = NULL;
	FILE* instructions_file = fopen("instructionTable.txt", "r");
	if (instructions_file == NULL ) {
		exit(1);
	}

	while (!feof(instructions_file)) {
		InstructionTable* new_inst = (InstructionTable*) malloc(
				sizeof(InstructionTable));
		fscanf(instructions_file, "%s", new_inst->mnemonic);
		fscanf(instructions_file, "%d", &new_inst->arguments);
		fscanf(instructions_file, "%hd", &new_inst->code);
		fscanf(instructions_file, "%d", &new_inst->size);

		new_inst->next = tb;
		tb = new_inst;
	}
	fclose(instructions_file);
	return tb;

}
